﻿/** 
 * Project Name:eleme-website 
 * File Name:SampleServiceImpl.java 
 * Package Name:com.eleme.service.impl 
 * Date:2017年12月22日下午3:42:09 
 * Copyright (c) 2017, fakedesigner@163.com All Rights Reserved. 
 * 
*/  
  
package com.eleme.service.impl;
import java.util.List;
import com.eleme.dao.IDaoFactory;
import com.eleme.dao.ISampleDao;
import com.eleme.dao.impl.UDaoFactory;
import com.eleme.entity.Sample;
import com.eleme.service.ISampleService;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

/** 
 * ClassName:SampleServiceImpl <br/> 
 * Function: TODO ADD FUNCTION. <br/> 
 * Reason:   TODO ADD REASON. <br/> 
 * Date:     2017年12月22日 下午3:42:09 <br/> 
 * @author   Pan 
 * @version   
 * @since    JDK 1.8 
 * @see       
 */
public class SampleServiceImpl extends BaseServiceImpl<Sample> implements ISampleService {

	private ISampleDao dao;
	
	public SampleServiceImpl(IDaoFactory factory) {
		super(factory.getSampleDao());
		dao = (ISampleDao) super.getDao();
	}

	public String getSampleJSON() {
		List<Sample> li = dao.getSamples();
		
		Gson gson = new GsonBuilder().create();
		return gson.toJson(li);
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		SampleServiceImpl ssi = new SampleServiceImpl(UDaoFactory.getInstance());
		System.out.println(ssi.getSampleJSON());
	}

}
